package main

import (
	"fmt"
	"time"
)

/**
 * @author: guangcheng
 * @date:   2020/11/11 21:57
 * @version  V1.0
 * @description:
 *
 */
func main() {

	now := time.Now()
	fmt.Println(now) //2020-11-11 21:58:13.7472601 +0800 CST m=+0.001993101

	fmt.Println("年:", now.Year())
	fmt.Println("月:", int(now.Month()))
	fmt.Println("日:", now.Day())
	fmt.Println("时:", now.Hour())
	fmt.Println("分:", now.Minute())
	fmt.Println("秒:", now.Second())

	//这份格式是指定的,不要改了...
	fmt.Println(now.Format("2006-01-02 15:04:05"))
	fmt.Println(now.Format("2006-01-02"))
	fmt.Println(now.Format("15:04:05"))
	fmt.Println(now.Format("01"))   //月份
	fmt.Println(now.Format("2006")) //年份
	fmt.Println(now.Format("02"))   //日

	i := 0
	for {
		i++
		fmt.Println(i)
		time.Sleep(time.Millisecond * 10)

		if i >= 100 {
			break
		}
	}

	//1605194402 1605194402974447500
	fmt.Println(now.Unix(), now.UnixNano())

}
